package experiment.e05.code.ch04.v2;

import experiment.e05.code.ch04.v0.Point;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/10/13 16:33
 * @package experiment.e05.code.ch04.v2
 * @description 矩形类
 */

public class Rectangle extends Shape {
    // 私有属性
    private double l;
    private double w;

    // 构造方法
    public Rectangle() {
    }

    public Rectangle(double l, double w) {
        this.l = l;
        this.w = w;
    }

    public Rectangle(Point point, double l, double w) {
        super(point);
        this.l = l;
        this.w = w;
    }

    // get && set
    public double getL() {
        return l;
    }

    public void setL(double l) {
        this.l = l;
    }

    public double getW() {
        return w;
    }

    public void setW(double w) {
        this.w = w;
    }

    /**
     * 获取面积
     *
     * @return
     */
    @Override
    public double getArea() {
        return l * w;
    }

    @Override
    public String toString() {
        return "Rectangle:{" + "l=" + l + ", w=" + w + ", " + super.toString() + "} ";
    }
}
